<object  id="LODOP" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>  
       <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed> 
</object> 
<script>
 var LODOP=getLodop(document.getElementById('LODOP'),document.getElementById('LODOP_EM'));
$(function(){
    $('#open_print_design').click(function(){
        LODOP.PRINT_INIT('');
        LODOP.PRINT_DESIGN();
    });
    $('td[edit]').dblclick(function(){
        var val = $(this).html();
        var field = $(this).attr('field');
        var wparam = $(this).parents().attr('wparam');
        var uuid = AUKEY+field+wparam;
        $(this).html("<input id='"+uuid+"' style='width:auto;' value='"+val+"' />");
        $('#'+uuid).focus().live('blur',function(){
            var now_val = $(this).val();
            var td_obj = $(this).parents('td');
            $.post(location.href,{val:now_val,field:field,wparam:wparam,type:'fast_edit'},function(data){
                if (data.state <= 0)
                {
                    alert(data.message);
                    td_obj.html(val);
                }
                else
                {
					 alert(data.message);
                    //dialogMessage(data.message,'green');
                    td_obj.html(now_val);
                }
            },'json');
        });
    });
    // 删除
    $('img[del]').click(function (){
        var delete_object_id = $(this).attr('del');
        $.post(location.href,{id:delete_object_id,type:'delete'},function(data){
            if (data.state <= 0)
            {
                alert(data.message);
                return false;
            }
            else
            {
				 alert(data.message);
                //dialogMessage(data.message,'green');
            }
        },'json');
        $('tr[wparam='+delete_object_id+']').remove();
    });
    // 快速添加
    $('#fast_add').submit(function(){
        var data = $(this).serialize()+'&app=<?php echo APP; ?>&mod=<?php echo MOD; ?>';
        $.post('system.php',data,function(data){
            if (data.state <= 0)
            {
                alert(data.message);
                return false;
            }
			 alert(data.message);
            //dialogMessage(data.message,'green');
            location.href = location.href;
        },'json');
        return false;
    });
    $('.span_now').click(function(){
        var edv = $('.edit_div');
        edv.css('display',edv.css('display') == 'none' ? 'block' : 'none');
    });
});
</script>


<table width="100%" cellpadding="0" cellspacing="0" border="0" class="table1">
       <tr>
            <th class="th0">编号</th>
            <th class="th1">模板名称</th>
            <th class="th0">操作</a>
       </tr>
       <?php foreach((array)$this->templates as $template): ?>
       <tr wparam='<?php echo $template['pid']; ?>'>
            <td><?php echo $template['pid']; ?></td>
            <td edit field='name'><?php echo $template['name']; ?></td>
            <td><?php echo opt('edit',"javascript:;",'id="'.$template['pid'].'"').opt('trash','javascript:;',"del='{$template['pid']}'"); ?></td>
       </tr>
       <?php endforeach; ?>
</table>
<div class="page_num">
     <div class="fr">
        <span>提示：双击编辑，鼠标点击页面其他处提交修改，</span>
     </div>
</div>
<div class="line_1"></div>
<div class="edit_tab tab"><div class="bg1"><div class="bg2"><span class="span_now">快速添加</span></div></div></div>
<div class="edit_div" style="display:none">
    <div class="line_1"></div><form id="fast_add" onSubmit="return false;">
    <div class="form_div1">
        <span class="span1">模板名称</span>
        <span><input type="text" name="name" /></span>
    </div>
    <div class="line_1"></div>
    <div class="form_div1">
        <span class="span1">模板内容</span>
        <span><a href="javascript:;" id="open_print_design">打开设计器</a><br/><textarea name="content" style="height:400px;width:400px"></textarea></span>
    </div>
    <div class="line_1"></div>
    <div class="form_div1"><span class="span1"></span><span><?php echo showhide('type','add'); ?><input type="submit" value="提交" class="btn1"/><input type="reset" class="btn1"/></span></div></form>
</div>